package com.example.smartcity.ui.smartCity.activitytModule

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AlertDialog
import com.example.smartcity.R
import com.example.smartcity.databinding.ActivityLogIssueBinding
import com.example.smartcity.logic.utils.Toast.Companion.showToast

class logIssueActivity : AppCompatActivity() {
    private lateinit var mBinding: ActivityLogIssueBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mBinding = ActivityLogIssueBinding.inflate(layoutInflater)
        setContentView(mBinding.root)
        title = "建言献策"
        supportActionBar?.setDisplayHomeAsUpEnabled(true)


        mBinding.logIssueOk.setOnClickListener {
            if (mBinding.logIssueTitle.text.isEmpty() || mBinding.logIssueContend.text.isEmpty()) "标题或内容不能为空哦！".showToast()
            else apply {
                AlertDialog.Builder(this).apply {
                    setTitle("提示")
                    setMessage("提交成功！")
                    setPositiveButton("确定"){ _, _ ->
                        mBinding.logIssueTitle.setText("")
                        mBinding.logIssueContend.setText("")
                    }
                    show()
                }
            }
        }
    }


    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        this@logIssueActivity.finish()
        return super.onOptionsItemSelected(item)
    }
}